

function modal_div_creator(id, className, textContent) {
    var div = document.createElement('div');
    div.id = id;
    div.className = className;
    div.textContent = textContent;
    return div;
}

function modal_button_creator(id, textContent) {
    var button = document.createElement('button');
    button.id = id;
    button.className = 'modal-btn';
    button.textContent = textContent;
    return button;
}
function modal_tr_creator(id, className) {
    var tr = document.createElement('tr');
    tr.id = id;
    tr.className = className;
    return tr;
}

function modal_td_creator(id, className, textContent) {
    var td = document.createElement('td');
    td.id = id;
    td.className = className;
    td.textContent = textContent;
    return td;
}

function display_alert_information(message) {
    var alertContainer = document.createElement('div');
    alertContainer.id = 'alert-container';
    alertContainer.className = 'modal-container';
    alertContainer.style.textAlign = 'left';

    // 创建modal-content div  
    var modalContent = document.createElement('div');
    modalContent.className = 'modal-content';
    modalContent.style.display = 'block';

    var alertHead = document.createElement('h2');
    alertHead.id = 'patient-head';
    alertHead.style.textAlign = 'center';
    alertHead.textContent = '提示信息';

    var error_message = modal_div_creator('alert_content', 'error_information', message);
    var cancel = modal_button_creator('cancel-button', '取消')

    modalContent.appendChild(alertHead)
    modalContent.appendChild(error_message)
    modalContent.appendChild(cancel)
    // 给取消按钮添加点击事件监听器  
    cancel.addEventListener('click', function () {
        if (alertContainer.parentNode) {
            alertContainer.parentNode.removeChild(alertContainer);
        }
    });

    alertContainer.appendChild(modalContent);

    document.body.appendChild(alertContainer);
}